﻿namespace Jacobi.ComponentModel.Decomposition
{
    partial class Pipe<T>
    {
        /// <summary>
        /// Port implementation class for consumer port
        /// </summary>
        private class ConsumerPort : IConsumerPort<T>
        {
            private Pipe<T> _pipe;

            public ConsumerPort(Pipe<T> pipe)
            {
                _pipe = pipe;
            }

            public T Read()
            {
                return _pipe.Read();
            }
        }

        /// <summary>
        /// Port implementation class for producer port.
        /// </summary>
        private class ProducerPort : IProducerPort<T>
        {
            private Pipe<T> _pipe;

            public ProducerPort(Pipe<T> pipe)
            {
                _pipe = pipe;
            }

            public void Write(T data)
            {
                _pipe.Write(data);
            }
        }

    }
}
